import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.StreamMessage;
import java.util.ArrayList;


public class printListen implements MessageListener {
    private ArrayList<Double> signals = new ArrayList<>();
    int i=0;
    String[] legends=new String[1];
    public void onMessage(Message message) {
        try {
            StreamMessage m=(StreamMessage)message;
            double mes=m.readDouble();
            System.out.println("收到的随机信号: "+mes);
            signals.add(mes);
            i=i+1;
            if(i%10==0)
            {
                ArrayList<ArrayList<Double>> data = new ArrayList<>();
                data.add(signals);
                legends[0]="signals";
                LineChart chart = new LineChart("primary signal", "primary signal",data,legends);
                chart.pack();
                chart.setVisible(true);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
